package com.zaki.controller;

import com.zaki.model.Result;
import com.zaki.utils.ALiYunUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@Slf4j
@RestController
public class FileUploadController {

    @Autowired
    private ALiYunUtil aLiYunUtil;

    @PostMapping("/upload")
    public Result uploadFile(MultipartFile file) throws Exception {
        log.info("文件上传，文件名：{}",file.getOriginalFilename());
        String filePath = aLiYunUtil.upload(file);
        log.info("文件上传完成，文件访问的路径：{}",filePath);
        return Result.success(filePath);
    }
}
